package controller

import (
	"demo/dao"
	"demo/models"
	"demo/vo"
	"errors"

	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
)

func Hello(ctx *gin.Context) {
	id := ctx.Param("id")
	var user models.SysUser
	var r vo.Result
	result := dao.GetDB().First(&user, id)
	if errors.Is(result.Error, gorm.ErrRecordNotFound) {
		r = vo.Error("记录不存在！")
	} else {
		r = vo.OK(user)
	}
	ctx.JSON(200, r)
}
